package com.dormms.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dormms.bean.ProclamationInfo;
import com.dormms.dto.ProclamationInfoRole;
import com.dormms.dto.ProclamationInfoRoleInfo;
import com.dormms.service.ProclamationService;
import com.dormms.tool.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
public class ProclamationController {
	@Autowired
	private ProclamationService proclamationService;
	
	@RequestMapping("super/queryProclamationByPageBySuper")
	@ResponseBody
	public PageInfo<ProclamationInfo> queryProclamationByPageBySuper(Page page, ProclamationInfo proclamationInfo){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<ProclamationInfo> proclamationInfos = proclamationService.queryProclamationInfoListByProclamationInfo(proclamationInfo);
		PageInfo<ProclamationInfo> pageInfo = new PageInfo<ProclamationInfo>(proclamationInfos);
		return pageInfo;
	}
	
	@RequestMapping("super/insertProclamation")
	@ResponseBody
	public Integer insertProclamation(ProclamationInfo proclamationInfo) {
		return proclamationService.insertProclamationInfo(proclamationInfo);
	}
	
	@RequestMapping("super/getAllProclamationInfo")
	@ResponseBody
	public List<ProclamationInfo> getAllProclamationInfo(){
		ProclamationInfo proclamationInfo = new ProclamationInfo();
		return proclamationService.queryProclamationInfoListByProclamationInfo(proclamationInfo);
	}
	
	@RequestMapping("super/insertProclamationInfoRole")
	@ResponseBody
	public Integer insertProclamationRoleInfo(ProclamationInfoRole proclamationInfoRole) {
		return proclamationService.insertProclamationRole(proclamationInfoRole);
	}
	
	@RequestMapping("super/updateProclamationBySuper")
	@ResponseBody
	public Integer updateProclamationBySuper(ProclamationInfo proclamationInfo) {
		return proclamationService.updateProclamationInfo(proclamationInfo);
	}
	
	@RequestMapping("super/deleteProclamation")
	@ResponseBody
	public Integer deleteProclamation(Integer proclamationId) {
		return proclamationService.deleteProclamation(proclamationId);
	}
	
	@RequestMapping("super/deleteProclamationRole")
	@ResponseBody
	public Integer deleteProclamationRole(Integer proclamationId, Integer roleId) {
		return proclamationService.deleteProclamationRole(proclamationId , roleId);
	}
	
	@RequestMapping("super/getProclamationAllRole")
	@ResponseBody
	public ProclamationInfoRoleInfo getProclamationAllRole(Integer proclamationId) {
		return proclamationService.queryProclamationInfoRoleInfoByProclamationId(proclamationId);
	}
	
	@RequestMapping("admin/queryProclamationByPageByadmin")
	@ResponseBody
	public PageInfo<ProclamationInfo> queryProclamationByPageByadmin(Page page, ProclamationInfo proclamationInfo){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<ProclamationInfo> proclamationInfos = proclamationService.queryAllProclamationInfoByRoleId(proclamationInfo,2);
		PageInfo<ProclamationInfo> pageInfo = new PageInfo<ProclamationInfo>(proclamationInfos);
		return pageInfo;
	}
	
	@RequestMapping("staff/queryProclamationByPageByStaff")
	@ResponseBody
	public PageInfo<ProclamationInfo> queryProclamationByPageByStaff(Page page, ProclamationInfo proclamationInfo){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<ProclamationInfo> proclamationInfos = proclamationService.queryAllProclamationInfoByRoleId(proclamationInfo,4);
		PageInfo<ProclamationInfo> pageInfo = new PageInfo<ProclamationInfo>(proclamationInfos);
		return pageInfo;
	}
	
	@RequestMapping("stu/queryProclamationByPageByStu")
	@ResponseBody
	public PageInfo<ProclamationInfo> queryProclamationByPageByStu(Page page, ProclamationInfo proclamationInfo){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<ProclamationInfo> proclamationInfos = proclamationService.queryAllProclamationInfoByRoleId(proclamationInfo,3);
		PageInfo<ProclamationInfo> pageInfo = new PageInfo<ProclamationInfo>(proclamationInfos);
		return pageInfo;
	}
	
	@RequestMapping("admin/getProclamationAllRole")
	@ResponseBody
	public ProclamationInfoRoleInfo getProclamationAllRoleByAdmin(Integer proclamationId) {
		return proclamationService.queryProclamationInfoRoleInfoByProclamationId(proclamationId);
	}
	
	@RequestMapping("staff/getProclamationAllRole")
	@ResponseBody
	public ProclamationInfoRoleInfo getProclamationAllRoleByStaff(Integer proclamationId) {
		return proclamationService.queryProclamationInfoRoleInfoByProclamationId(proclamationId);
	}
	@RequestMapping("stu/getProclamationAllRole")
	@ResponseBody
	public ProclamationInfoRoleInfo getProclamationAllRoleByStu(Integer proclamationId) {
		return proclamationService.queryProclamationInfoRoleInfoByProclamationId(proclamationId);
	}
}
